import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '@/views/Index'
import Login from '@/views/Login'
import Home from '@/views/Home'
import AllGoods from '@/views/AllGoods'
import GoodsDetail from '@/views/GoodsDetail'

Vue.use(VueRouter)

const routes = [{
        path: "/",
        // 重定向到home页面
        redirect: "/home",
        name: 'home',
        component: Index,
        children: [{
                path: "home",
                component: Home,
            },
            // 详情页路由
            {
                path: "goodsDetail",
                name: 'goodsDetail',
                component: GoodsDetail
            }
        ]
    },
    // 登录路由
    {
        path: "/login",
        name: 'lgoin',
        component: Login
    },
    // 注册路由
    {
        path: "/register",
        name: "register",
        // 文件指向
        component: () =>
            import ("@/views/Register/index.vue")
    },
    // 男装路由
    {
        path: "/allgoods",
        name: 'allgoods',
        component: AllGoods
    },
    // 购物车路由
    {
        path: "/shoppingcart",
        name: "shoppingcart",
        // 文件指向
        component: () =>
            import ("@/views/shop/shoppingcart.vue")
    },
    // 个人中心路由
    {
        path: "/mine",
        name: "mine",
        // 文件指向
        component: () =>
            import ("@/views/mine/mine.vue")
    }
]

const router = new VueRouter({
    // 把URL的#去掉
    // monde:'history',
    mode: 'history',
    routes
})

export default router